package gui;

import java.awt.Dimension;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.border.BevelBorder;

import RoomPanel.RoomPanelRemover;

public class PopUpMenu {

	private JMenuItem AddObject;
	private int id;
	private JMenuItem RemoveObject;
	private JMenuItem RemoveRoom;
	private JMenuItem RoomInfo;
	private JPopupMenu RoomPopUp;

	/**
	 * This method initializes AddObject
	 * 
	 * @return javax.swing.JMenuItem
	 */
	private JMenuItem getAddObject() {
		if (AddObject == null) {
			AddObject = new JMenuItem();
			AddObject.setText("Add Object");
		}
		return AddObject;
	}

	public int getId() {
		return id;
	}

	/**
	 * This method initializes RemoveObject
	 * 
	 * @return javax.swing.JMenuItem
	 */
	private JMenuItem getRemoveObject() {
		if (RemoveObject == null) {
			RemoveObject = new JMenuItem();
			RemoveObject.setText("Remove Object");
		}
		return RemoveObject;
	}

	/**
	 * This method initializes RemoveRoom
	 * 
	 * @return javax.swing.JMenuItem
	 */
	private JMenuItem getRemoveRoom() {
		if (RemoveRoom == null) {
			RemoveRoom = new JMenuItem();
			RemoveRoom.setText("Remove Room");
			RemoveRoom.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					RoomPanelRemover.remove(id);
				}
			});
		}
		return RemoveRoom;
	}

	/**
	 * This method initializes RoomInfo
	 * 
	 * @return javax.swing.JMenuItem
	 */
	private JMenuItem getRoomInfo() {
		if (RoomInfo == null) {
			RoomInfo = new JMenuItem();
			RoomInfo.setText("Room Information");

		}
		return RoomInfo;
	}

	public JPopupMenu getRoomPopUp() {
		if (RoomPopUp == null) {
			RoomPopUp = new JPopupMenu();
			RoomPopUp.setSize(new Dimension(80, 120));
			RoomPopUp.add(getRoomInfo());
			RoomPopUp.add(getAddObject());
			RoomPopUp.add(getRemoveObject());
			RoomPopUp.addSeparator();
			RoomPopUp.setBorder(new BevelBorder(BevelBorder.RAISED));
			RoomPopUp.add(getRemoveRoom());
		}
		return RoomPopUp;
	}

	public void setId(int id) {
		this.id = id;
	}
}
